package graph.drawingshapes.shapes
{
	import flash.text.TextField;
	import flash.text.TextFormat;

	public class TextShape extends RectangleShape
	{
		public static const NAME:String = "TextShape";
		public override function get getName():String
		{
			return NAME;
		}
		
		[Bindable]
		private var _text:String = "";
		[Bindable]
		public virtual function get text():String
		{
			return this._text;
		}
		public virtual function set text(value:String):void
		{
			if (value != this.text)
			{
				firePropertyChanged("text", this.text, value);
				this._text = value;
			}
		}
		
		
		[Bindable]
		private var _textColor:uint = 0xFF000000;
		[Bindable]
		public virtual function get textColor():uint
		{
			return this._textColor;
		}
		public virtual function set textColor(value:uint):void
		{
			if (value != this.textColor)
			{
				firePropertyChanged("textColor", this.textColor, value);
				this._textColor = value;
			}
		}
		
		public function TextShape(x:Number=DefaultX, y:Number=DefaultY, width:Number=DefaultWidth, height:Number=DefaultHeight)
		{
			super(x, y);
		}
		
		protected virtual function removeAll():void
		{
			while (this.numChildren > 0)
			{
				this.removeChildAt(0);
			}
		}
		
		protected override function draw():void
		{		
			var textObj:TextField = new TextField();
			textObj.text = this.text;
			textObj.textColor = this.textColor;
			textObj.width = this.width;
			textObj.height = this.height;
			textObj.multiline = true;
			textObj.setTextFormat(new TextFormat("Arial", 20, textColor, true, false, true));
			this.addChild(textObj);
		}
		
	}
}